package com.slwish.xty.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.slwish.xty.R;
import com.slwish.xty.entity.CreditLifeModel;

import java.util.List;

/**
 * 模块说明：
 *
 * @author 陈浩
 * @date 2017/11/30
 */

public class CreditLifeChildAdapter extends BaseQuickAdapter<CreditLifeModel.CreditLife, BaseViewHolder> {

    public CreditLifeChildAdapter(@Nullable List<CreditLifeModel.CreditLife> data) {
        super(R.layout.item_credit_life_child, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, CreditLifeModel.CreditLife item) {
        holder.setText(R.id.tv_message, item.getName());
//        holder.itemView.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//
//            }
//        });
        ImageView iv = holder.getView(R.id.iv);
        RequestOptions options = RequestOptions.centerCropTransform().placeholder(R.mipmap.icon_default)
                .error(R.mipmap.icon_default);
        if (item.getImgUrl() == null || item.getImgUrl().equals("")) {
            iv.setImageResource(R.mipmap.icon_default);
        } else {
            Glide.with(mContext)
                    .load(item.getImgUrl())
                    .apply(options)
                    .into(iv);
        }
    }
}
